
import { dispatch} from './dispatcher';
import { Session, Application } from 'pinus';

export function aviator(session: Session, msg: any, app: Application, cb: (err: Error, serverId ?: string) => void) {
    let aviatorServers = app.getServersByType('aviator');
    if(!aviatorServers || aviatorServers.length === 0) {
        cb(new Error('can not find aviator servers.'));
        return;
    }
    cb(null, aviatorServers[0].id)
}

export function hall(session: Session, msg: any, app: Application, cb: (err: Error, serverId ?: string) => void) {
    let hallServers = app.getServersByType('hall')
    if (!hallServers || hallServers.length === 0) {
        cb(new Error('can not find hall servers.'))
        return
    }
    let res = dispatch(session.uid, hallServers)
    cb(null, res.id)
}
